﻿@model IEnumerable<SIOGDE.AccesoDatos.Entidades.Lites.UnidadAsignadaInfo>

@{
    ViewBag.Title = "Info";
}

<link href="~/Content/DataForm.css" rel="stylesheet" />
 

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
                <script language="javascript" type="text/javascript">
                    $(document).ready(function () {

                        var bounds = new google.maps.LatLngBounds();
                        var options = {
                            zoom: 10,
                            center: new google.maps.LatLng(-17.434511, -66.225586),
                            mapTypeId: google.maps.MapTypeId.TERRAIN
                        };
                        var googleMap = new google.maps.Map($("#map")[0], options);
                        var infoWindow = new google.maps.InfoWindow({ content: "Cargando..." });

                        $.ajax({
                            type: "POST",
                            url: "GetSugerenciaJson",
                            datatype: "json",
                            success: function (data) {
                                for (var i = 0; i < data.length; i++) {

                                    var point = new google.maps.LatLng(data[i].Latitud, data[i].Longitud);

                                    bounds.extend(point);

                                    var marker = new google.maps.Marker({
                                        position: point,
                                        map: googleMap,
                                        html: data[i].Descripcion,
                                        icon: '/Content/Images/house.png',
                                        animation: google.maps.Animation.DROP
                                    });

                                    google.maps.event.addListener(marker, "click", function () {
                                        infoWindow.setContent(this.html);
                                        infoWindow.open(googleMap, this);
                                    });

                                    var results = document.getElementById('results');
                                    var tr = document.createElement('tr');
                                    //tr.style.backgroundColor = i % 2 == 0 ? '#F0F0F0' : '#FFFFFF';
                                    tr.onclick = function () { google.maps.event.trigger(marker, 'click'); }
                                    tr.onmouseover = function () { google.maps.event.trigger(marker, 'click'); }

                                    var nametd = document.createElement('td');
                                    
                                    var pReg = document.createElement("p");
                                    pReg.className = "TextBoxStyle";

                                    var name = document.createTextNode(data[i].Nombre);
                                    pReg.appendChild(name);

                                    var a = document.createElement('a');
                                    var linkText = document.createTextNode('Elegir esta unidad');
                                    a.className = 'button medium orange';
                                    a.appendChild(linkText);
                                    a.title = "Elegir esta unidad";
                                    a.href = "/UnidadMilitar/Confirmar?guidReq=" + data[i].GuidRequerimiento;
                                    pReg.appendChild(a);
                                                                        

                                    nametd.appendChild(pReg);
                                    tr.appendChild(nametd);
                                    results.appendChild(tr);

                                }
                            }

                        });

                        //googleMap.fitBounds(bounds);






                    });
                </script>


@using (Html.BeginForm("Delete", "Arma", FormMethod.Post, new { @class = "box Common", @id = "myDataForm" }))
{
    <div class="header">
       Elegir Destino
    </div>    
    
    <table style="padding : 10px;" width="100%">
       <tr>          
           <td width="300px" id="results">


             @*  @foreach (var model in @Model)
                {             
                    <p class="TextBoxStyle">
                    <img src="@Url.Action("Imagen" ,"Media" , new { guid = model.GuidUnidad })" height="50"/>
                        @Html.DisplayFor(modelItem =>  model.Nombre)   
                        @Html.ActionLink("Elegir Destino", "Confirmar", "UnidadMilitar", new { guidReq = model.GuidRequerimiento}, new { @class = "button medium green" })
                    </p>
               }*@

           </td>
           
           <td width="100%">               
               
               <div id="map" style="height:500px">
                </div>


           </td>          
       </tr>
       

    </table>
    
    
   
    
     <footer>    
         <input type="button" class="btnCancel" value ="Cancelar y Regresar" onclick="history.go(-1);"/>	    
	</footer>
}

